package com.cn.xiaonuo.tcrfinance.tcrusers.controller;

import com.cn.xiaonuo.common.entity.BusinessMessage;
import com.cn.xiaonuo.common.utils.ApiJsonModel;
import com.cn.xiaonuo.tcrfinance.tcrusers.param.PvUserParam;
import com.cn.xiaonuo.tcrfinance.tcrusers.param.XczxGwqBillDetailsParam;
import com.cn.xiaonuo.tcrfinance.tcrusers.service.PvHpcGwjService;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * 购物卷管理
 *
 * @author
 */
@RestController
public class HpcGwjController {

    @Autowired
    private PvHpcGwjService pvHpcGwjService;

    //管理后台购物券总和
    @ApiOperation(value = "和平村购物卷收支记录-列表", notes = "和平村购物卷收支记录-列表")
    @ApiJsonModel({
            @ApiModelProperty(name = "userId", value = "用户ID",example = "10086"),
            @ApiModelProperty(name = "pageSize", value = "每页显示多少数量",example = "10",required = true),
            @ApiModelProperty(name = "pageNo", value = "页数",example = "1",required = true)
    })
    @PostMapping("/api/gwj/selectBackGwjAmounts")
    public BusinessMessage selectBackGwjAmounts(@RequestBody Map<String, Object> params) {
       return pvHpcGwjService.selectBackGwjAmounts(params);
    }



    //管理后台购物券明细
    @ApiOperation(value = "和平村购物卷收支记录-消费、到帐明细", notes = "和平村购物卷收支记录-消费、到帐明细")
    @ApiJsonModel({
            @ApiModelProperty(name = "type", value = "查询类型",example = "2"),
            @ApiModelProperty(name = "userId", value = "用户ID",example = "10086"),
            @ApiModelProperty(name = "begin", value = "开始时间（LONG）",example = "15686555650",required = true),
            @ApiModelProperty(name = "end", value = "结束时间（LONG）",example = "15685558885",required = true)
    })
    @PostMapping("/api/gwj/selectBackGwjDetail")
    public BusinessMessage selectBackGwjDetail(@RequestBody Map<String, Object> params) {
        return pvHpcGwjService.selectBackGwjDetail(params);
    }

    @ApiOperation(value = "添加购物券", notes = "添加购物券")
    @PostMapping("/api/gwj/addGwjByFinance")
    public BusinessMessage addGwjByFinance(@RequestBody Map<String, Object> params, HttpServletRequest request) {
        return pvHpcGwjService.addGwjByFinance(params,request);
    }
    @ApiOperation(value = "输入IP", notes = "输入IP")
    @PostMapping("/api/gwj/selectAddGwjIp")
    public BusinessMessage selectAddGwjIp() {
        return pvHpcGwjService.selectAddGwjIp();
    }
    @ApiOperation(value = "更新购物卷", notes = "更新购物卷")
    @PostMapping("/api/gwj/updateAddGwjIp")
    public BusinessMessage updateAddGwjIp(@RequestBody Map<String, Object> params) {
        return pvHpcGwjService.updateAddGwjIp(params);
    }

    //管理后台购物券明细
    @ApiOperation(value = "消费/到账记录", notes = "消费/到账记录")
    @PostMapping("/api/gwj/consumDetail")
    public BusinessMessage consumDetail(@RequestBody PvUserParam pvUserParam) {
        return pvHpcGwjService.consumDetail(pvUserParam);
    }

    /**
     *
     * @param param
     * @return
     */
    @ApiOperation(value = "乡村振兴购物券流水", notes = "乡村振兴购物券流水")
    @PostMapping("/api/gwj/xczxGwjLog")
    public BusinessMessage xczxGwjLog(@RequestBody XczxGwqBillDetailsParam param) {
        return pvHpcGwjService.xczxGwjLog(param);
    }

    /**
     *
     * @param param
     * @return
     */
    @ApiOperation(value = "乡村振兴、一县一品购物券余额", notes = "乡村振兴、一县一品购物券余额")
    @PostMapping("/api/gwj/gwqBalance")
    public BusinessMessage gwqBalance(@RequestBody XczxGwqBillDetailsParam param) {
        return pvHpcGwjService.gwqBalance(param);
    }

    /**
     *
     * @param param
     * @return
     */
    @ApiOperation(value = "乡村振兴购物券流水", notes = "乡村振兴购物券流水")
    @GetMapping(value = "/api/gwj/xczxGwjLogExcel")
    public void xczxGwjLogExcel(XczxGwqBillDetailsParam param,HttpServletResponse response) throws Exception{
          pvHpcGwjService.xczxGwjLogExcel(param,response);
    }
}
